// pages/details/details.js
import goodsArr from "../../goodsArr"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbarHeigt: 0,
    navbarTop: 0,
    white:false,
  },
  onPageScroll : function (e) {
    let that = this
    // console.log(e,that.data.white)
    let height =this.data.navbarHeigt+this.data.navbarTop+10;
    let stickyRes = e.scrollTop > height ?  true : false
    if (that.data.white === stickyRes) {
      return false
    }
    this.setData({
      white: stickyRes,
      //此时都为真，说明1.要固定到顶部 2.可视区域垂直滚动距离已经大于了150px
    })
    /**
     * @note
     * 这里虽然也有判断，但是每次判断都会调用setData,上面只是每次判断stickyRes得值
     */
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.pageSetting()
    let that = this
    wx.getStorage({
      key: 'roomItem',
      success(res) {

        console.log("11", res.data.currentTarget.dataset.item)
        that.setData({
          houseinfos: res.data.currentTarget.dataset.item,
          roomsArr: goodsArr.orderInfo
        })
      },
      fail(res) {
        console.log(res)
      }
    })

  },
  callthiskeeper(e) {
    console.log(e)
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.item.phone //仅为示例，并非真实的电话号码
    })
  },
  back() {
    // 跳转至上一级
    // wx.navigateBack({
    //   delta: 1,
    // })

    // 临时跳转
    wx.switchTab({
      url: '../index/index',
    })
  },
  pageSetting() {
    // 获取系统信息，设置导航栏上边距
    let res = wx.getSystemInfoSync()
    console.log(res)

    // 设置
    let capsule = wx.getMenuButtonBoundingClientRect()
    console.log(capsule)
    this.setData({
      navbarHeigt: capsule.height,
      navbarTop: capsule.top,
      navbarRight: capsule.right,
      navbarBottom: capsule.bottom
    })
  },
  // 打电话2联系管家
  callKeeper() {
    wx.makePhoneCall({
      phoneNumber: '4001001111194144' //仅为示例，并非真实的电话号码
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },


})